import axios from '@/utils/request';

/**
 * 一级分类
 * @param params 查询条件
 */
export async function list(params) {
 
  const res = await axios.get('/figure.account/index', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 添加
 * @param data 机构信息
 */
export async function add(data) {
  const res = await axios.post('/figure.account/add', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}



/**
 * 审核
 * @param params nid oid 两个排序的id
 */
 export async function check(data) {
  const res = await axios.post('/figure.account/check', data);
  if (res.data.code === 0) {
      return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 修改
 * @param data 机构信息
 */
export async function update(data) {
  const res = await axios.post('/figure.account/edit', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 排序
 * @param params nid oid 两个排序的id
 */
 export async function sortChange(params) {
  const res = await axios.post('/figure.account/sortChange', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 排序
 * @param params nid oid 两个排序的id
 */
 export async function modify(data) {
  const res = await axios.post('/figure.account/modify', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除
 * @param id id
 */
export async function remove(id) {
  const res = await axios.get('/figure.account/delete?id=' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 重置密码
 * @param params nid oid 两个排序的id
 */
 export async function resetPassword(id) {
  const res = await axios.post('/figure.account/resetPassword?id=' + id);
  if (res.data.code === 0) {
      return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 重置秘钥
 * @param params 
 */
 export async function resetKey(id) {
  const res = await axios.post('/figure.account/resetKey?id=' + id);
  if (res.data.code === 0) {
      return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}



/**
 * 详情
 * @param id id
 */
 export async function info(id) {
  const res = await axios.get('/figure.account/info?id=' + id);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 详情
 * @param id id
 */
 export async function statis() {
  const res = await axios.get('/figure.account/statis' );
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改
 * @param data 机构信息
 */
 export async function infoEdit(data) {
  const res = await axios.post('/figure.account/infoEdit', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 详情
 * @param id id
 */
 export async function infoDetail() {
  const res = await axios.get('/figure.account/infoDetail');
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


export async function site(params) {
 
  const res = await axios.get('/figure.account/site', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function operationUser(params) {
 
  const res = await axios.get('/figure.account/operationUser', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function operationUserExport(params) {

    const res = await axios.get('/figure.account/operationUserExport', {
        params
    });
    if (res.data.code === 0) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
}

export async function agent(params) {
 
  const res = await axios.get('/figure.account/agent', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function agentExport(params) {

    const res = await axios.get('/figure.account/agentExport', {
        params
    });
    if (res.data.code === 0) {
        return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
}